package com.sxj.corejava.code09_集合.List;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author 石小俊
 * 2024年07月24日 9:53
 */
public class Test03_与数组的转换 {

    public static void main(String[] args) {
        //toArray();
        toList();
    }

    public static void toArray() {
        ArrayList list = new ArrayList();
        list.add(1);
        list.add("admin");
        list.add(true);
        list.add(3.14);
        Object[] arr = list.toArray();
        System.out.println(Arrays.toString(arr));
    }

    public static void toList() {
        String[] arr = {"admin", "alex", "alice", "jack", "tom"};
        List<String> list = Arrays.asList(arr);
        System.out.println(list);

        List<Integer> list2 = Arrays.asList(1, 3, 4, 5, 6, 7, 8);
        System.out.println(list2);

        ArrayList<Integer> list3 = new ArrayList<>(Arrays.asList(1, 3, 6, 5, 8, 9, 11, 13));
        System.out.println(list3);
    }

}
